package org.jeecg.common.util.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author guoyh
 * @ClassName SexEnum
 * @Description
 * @since 2020/8/16 01:36
 **/
@Getter
@AllArgsConstructor
public enum SexEnum {

    MALE(1,"男"),
    FEMALE(2,"女"),
    UNKNOWN(0,"未知");

    private int code;

    private String desc;

    public static SexEnum getInstance(Integer code){
        return Arrays.stream(values()).filter(item -> Objects.equals(code,item.getCode())).findFirst().orElse(UNKNOWN);
    }
}
